var ajaxHelper = require("../../utils/ajaxhelp");
const serviceUrl = getApp().globalData.serviceUrl;
let token = wx.getStorageSync('token');

const getStreetByPAC = (provinceName, cityName, areaName) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Street/GetStreetByPCA", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		provinceName: provinceName,
		cityName: cityName,
		areaName: areaName
	})
}

const getStreetDetail = (streetId) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Street/GetStreetById", {}, "GET", {
		streetId: streetId
	})
}

const modStreetInfo = (streeet = {}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Street/Post", {
		'Authorization': 'Bearer ' + token
	}, "POST", streeet)

}

const addStreetInfo = (streeet = {}) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Street/Put", {
		'Authorization': 'Bearer ' + token
	}, "POST", streeet)

}

const getStreetByName = (streetName, provinceName, cityName, areaName) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/Street/GetStreetByName", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		streetName: streetName,
		provinceName: provinceName,
		cityName: cityName,
		areaName: areaName
	});
}


module.exports = {
	getStreetByPAC,
	getStreetDetail,
	modStreetInfo,
	getStreetByName,
	addStreetInfo,
}
